# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=aardvark-dns
_commit=dc9331e1746f3bf0395ecd957dce8f341e4ed083  # refs/tags/v1.8.0
pkgver=1.8.0
pkgrel=1
pkgdesc="Authoritative dns server for A/AAAA container records"
arch=(loong64 x86_64)
url="https://github.com/containers/aardvark-dns"
license=(Apache-2.0)
depends=(
  gcc-libs
  glibc
)
makedepends=(
  cargo
  git
  libgit2
)
source=(git+https://github.com/containers/aardvark-dns.git#tag=$_commit)
sha256sums=('SKIP')
# NOTE: pinning commit until upstream clarifies commitment to chain of trust:
# https://github.com/containers/aardvark-dns/issues/83
# validpgpkeys=('74FE091D25519980B2D84447160386BECB6F0643')  # Brent Baude <bbaude@redhat.com>

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/v//g'
}

prepare() {
  cd $pkgname
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target

  cd $pkgname
  cargo build --frozen --release --all-features
}

check() {
  export RUSTUP_TOOLCHAIN=stable

  cd $pkgname
  cargo test --frozen --all-features
}

package() {
  cd $pkgname
  install -vDm 755 target/release/$pkgname -t "$pkgdir/usr/lib/podman/"
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
